#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
int main(){
	int count;
	cin>>count;
	int *point;
	point=(int*)malloc(sizeof(int)*count);
	for(int i=1;i<=count;i++){
		point[i-1]=i;
	}
	do{
		for(int i=0;i<count;i++)
			cout<<point[i];
		cout<<endl;
	}while(next_permutation(point,point+count));
}